package com.pic.mgt.syushin.executer;

import java.io.File;

import com.pic.mgt.log.IgxLog;
import com.pic.mgt.unit.Business;
import com.pic.mgt.unit.operation.BusinessUnitOperation;
import com.pic.mgt.unit.operation.UnitOperationException;

public final class BatchConfirmationFileProcess implements CfmtAction {
	// (送多方刪除)
	//private String syushinBucketTmpPathStr;
	private BusinessUnitOperation simpleBusinessUnitOperation;
	
	@Override
	public void build(Business business, File destFolder) throws BuildCfmtFileProcessException {
		// (送多方刪除)
		/*File syushinBusinessBucketTmpPath = new File(syushinBucketTmpPathStr,
													 business.getBusinessName());*/
		try {
			// ********************** Log **********************
			if (IgxLog.messageDetailsLog.isInfoMode()) {
				IgxLog.messageDetailsLog.info(this,
						"Shifting confirmation file '{}' to syushin bucket tmp.",
						business.getConfirmationFilename());
			}
			// ********************** Log **********************
			
			// 搬移確認檔案
			// (送多方修改)
			this.simpleBusinessUnitOperation.moveConfirmationFile(business, destFolder);
			
			// ********************** Log **********************
			if (IgxLog.messageDetailsLog.isInfoMode()) {
				IgxLog.messageDetailsLog.info(this,
						"Shifting confirmation file '{}' to syushin bucket tmp completed.",
						business.getConfirmationFilename());
			}
			// ********************** Log **********************
		} catch (UnitOperationException e) {
			throw new BuildCfmtFileProcessException(
					"Shifting confirmation file '" +
					business.getConfirmationFilename() + 
					"' to syushin bucket tmp failed.", e);
		}
	}
	
	// --- getter and setter ---
	
	// (送多方刪除)
	/*public void setSyushinBucketTmpPathStr(String syushinBucketTmpPathStr) {
		this.syushinBucketTmpPathStr = syushinBucketTmpPathStr;
	}*/

	public void setSimpleBusinessUnitOperation(
			BusinessUnitOperation simpleBusinessUnitOperation) {
		this.simpleBusinessUnitOperation = simpleBusinessUnitOperation;
	}

}
